<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是使用repo——从0搭建一个repo管理的项目的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV03-repo-03-从0搭建一个repo管理的项目">
<meta property="og:url" content="https://sumumm.github.io/post/58627ebd.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是使用repo——从0搭建一个repo管理的项目的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240927225008913.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240927225805883.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928071506236.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928071707655.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928073314969.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928073525695.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928073725564.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928073901142.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240927230359007.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20241025193101054.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20241025193736299.png">
<meta property="article:published_time" content="2024-10-26T14:41:00.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.071Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="Git">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240927225008913.png">


<link rel="canonical" href="https://sumumm.github.io/post/58627ebd.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":"","permalink":"https://sumumm.github.io/post/58627ebd.html","path":"post/58627ebd.html","title":"LV03-repo-03-从0搭建一个repo管理的项目"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV03-repo-03-从0搭建一个repo管理的项目 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E6%A6%82%E8%A6%81"><span class="nav-text">一、概要</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C"><span class="nav-text">二、准备工作</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-repo%E5%B7%A5%E5%85%B7%E5%AE%89%E8%A3%85"><span class="nav-text">1. repo工具安装</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-repo%E6%BA%90%E7%A0%81"><span class="nav-text">2. repo源码</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E4%BD%BF%E7%94%A8%E6%B8%85%E5%8D%8E%E6%BA%90"><span class="nav-text">2.1 使用清华源</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-fork%E6%BA%90%E7%A0%81"><span class="nav-text">2.2 fork源码</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E6%B8%85%E5%8D%95%E5%BA%93"><span class="nav-text">3. 清单库</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%89%E3%80%81%E7%9B%B8%E5%85%B3%E5%91%BD%E4%BB%A4"><span class="nav-text">三、相关命令</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-repo-init"><span class="nav-text">1. repo init</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-1-%E5%91%BD%E4%BB%A4%E8%AF%B4%E6%98%8E"><span class="nav-text">1.1 命令说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-2-%E5%91%BD%E4%BB%A4%E5%8F%82%E8%80%83"><span class="nav-text">1.2 命令参考</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-3-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">1.3 使用实例</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-4-%E6%8C%87%E5%AE%9A%E6%B8%85%E5%8D%95%E6%96%87%E4%BB%B6%E5%90%8D"><span class="nav-text">1.4 指定清单文件名</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#1-5-%E6%8C%87%E5%AE%9A%E6%B8%85%E5%8D%95%E5%BA%93%E5%90%8D"><span class="nav-text">1.5 指定清单库名</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-repo-sync"><span class="nav-text">2. repo sync</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#2-1-%E5%91%BD%E4%BB%A4%E8%AF%B4%E6%98%8E"><span class="nav-text">2.1 命令说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">2.2 使用实例</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-repo-start"><span class="nav-text">3. repo start</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#3-1-%E5%91%BD%E4%BB%A4%E8%AF%B4%E6%98%8E"><span class="nav-text">3.1 命令说明</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-2-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">3.2 使用实例</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/58627ebd.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV03-repo-03-从0搭建一个repo管理的项目 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV03-repo-03-从0搭建一个repo管理的项目
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2024-10-26 22:41:00" itemprop="dateCreated datePublished" datetime="2024-10-26T22:41:00+08:00">2024-10-26</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/" itemprop="url" rel="index"><span itemprop="name">开发工具</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/" itemprop="url" rel="index"><span itemprop="name">03版本控制</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>4.9k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>18 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是使用repo——从0搭建一个repo管理的项目的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" rowspan="5">PC端开发环境</td>        <td align="center" width=150px>Windows</td>        <td align="left">Windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu20.04.2的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 17 Pro</td>        <td align="left">17.6.0 build-24238078</td>      </tr>    <tr>        <td align="center">终端软件</td>        <td align="left">MobaXterm(Professional Edition v23.0 Build 5042 (license))</td>    </tr>    <tr>        <td align="center">Win32DiskImager</td>        <td align="left">Win32DiskImager v1.0</td>      </tr>    <tr>        <td align="center" rowspan="3">Linux开发板环境</td>        <td align="center">Linux开发板</td>        <td align="left">正点原子 i.MX6ULL Linux 阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr><td align="center">参考资料  </td><td align="center">相关说明</td></tr>    <tr><td align="left">Git 官网</td><td align="left"><a href="https://git-scm.com/" target="_blank">https://git-scm.com/ <i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left">Git 官方文档</td><td align="left"><a href="https://git-scm.com/doc" target="_blank">https://git-scm.com/doc <i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left">Pro Git Book</td><td align="left"><a href="https://git-scm.com/book/zh/v2" target="_blank">https://git-scm.com/book/zh/v2 <i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left">Git 快速使用指南</td><td align="left"><a href="https://training.github.com/downloads/zh_CN/github-git-cheat-sheet/" target="_blank">https://training.github.com/downloads/zh_CN/github-git-cheat-sheet/ <i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left">Visual Git Cheat Sheet</td><td align="left"><a href="https://ndpsoftware.com/git-cheatsheet.html#loc=index" target="_blank">https://ndpsoftware.com/git-cheatsheet.html#loc=index <i class="fa fa-external-link-alt"></i> </a></td></tr>    <tr><td align="left">Repo 工具使用介绍 - Gitee.com</td><td align="left"><a href="https://gitee.com/help/articles/4316#article-header0" target="_blank">https://gitee.com/help/articles/4316#article-header0 <i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">分类</td>        <td align="center">网址</td>        <td align="center">说明</td>    </tr>    <tr>        <td align="center" rowspan="0">---</td>        <td align="left"><a href="" target="_blank">---</a></td>        <td align="left">---</td>    </tr></table>
              </div>
            </details>

<h1 id="一、概要"><a href="#一、概要" class="headerlink" title="一、概要"></a><font size=3>一、概要</font></h1><p>前面我们已经知道了，repo是git仓库的管理工具，它能更方便的管理由若干个git仓库组成的项目。它是python脚本，平常我们操作的repo命令只是一个入口，其实它还有一个git仓库，是一系列python脚本的集合。</p>
<p>repo通过清单文件（.xml）来管理。清单文件里记录了所有的git仓库信息。也可以当作是项目的快照，根据某一个清单文件，就能将整个项目里的所有git仓库都还原到生成清单文件时的状态。所有的清单需要一个git仓库管理。</p>
<p>所需要的东西和教程，可以参考这两个地方：</p>
<p><a target="_blank" rel="noopener" href="https://source.android.google.cn/docs/setup/download?hl=zh-cn#installing-repo">下载 Android 源代码  | Android Open Source Project (google.cn)</a></p>
<p><a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/">AOSP | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror</a></p>
<h1 id="二、准备工作"><a href="#二、准备工作" class="headerlink" title="二、准备工作"></a><font size=3>二、准备工作</font></h1><h2 id="1-repo工具安装"><a href="#1-repo工具安装" class="headerlink" title="1. repo工具安装"></a><font size=3>1. repo工具安装</font></h2><p>这个在前面已经安装过了。</p>
<h2 id="2-repo源码"><a href="#2-repo源码" class="headerlink" title="2. repo源码"></a><font size=3>2. repo源码</font></h2><p>repo的源码：不仅仅是repo命令那一个脚本，而是repo的源码库，源码库中也会有repo命令。前面我们知道在进行repo init的时候是要进行repo源码的下载的，一般来讲，默认是从官方网站：<a target="_blank" rel="noopener" href="https://gerrit.googlesource.com/git-repo">https://gerrit.googlesource.com/git-repo</a>，但是这里呢，我们又必须要科学上网，所以有两种办法。</p>
<h3 id="2-1-使用清华源"><a href="#2-1-使用清华源" class="headerlink" title="2.1 使用清华源"></a><font size=3>2.1 使用清华源</font></h3><p>参考文档在这里：<a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/">AOSP | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror</a>，然后我们可以按照说明，一步一步操作。这个方式的话需要修改一下环境变量，但是其实命令改一下也行，不过还是改环境变量吧，方便一点：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">echo &quot;export REPO_URL=&#x27;https://mirrors.tuna.tsinghua.edu.cn/git/git-repo&#x27;&quot; &gt;&gt; ~/.bashrc</span><br><span class="line">source ~/.bashrc</span><br></pre></td></tr></table></figure>

<h3 id="2-2-fork源码"><a href="#2-2-fork源码" class="headerlink" title="2.2 fork源码"></a><font size=3>2.2 fork源码</font></h3><p>这种方式当然就是在自己的github或者gitee中创建一个源码仓库就行了，可以从这里fork：<a target="_blank" rel="noopener" href="https://github.com/GerritCodeReview/git-repo">GerritCodeReview&#x2F;git-repo: repo - The Multiple Git Repository Tool - (mirror of https://gerrit.googlesource.com/git-repo) (github.com)</a>。</p>
<blockquote>
<p>说明：我没用这个，这个毕竟还是github，有时候也访问不了，我后面用的都是清华源的了。</p>
</blockquote>
<h2 id="3-清单库"><a href="#3-清单库" class="headerlink" title="3. 清单库"></a><font size=3>3. 清单库</font></h2><p>自己建一个叫manifest名字的git库，用来存放清单文件就可以。注意，<strong>必须至少有一个清单文件，这样才能根据清单文件拉代码，之后也才能生成新的清单文件。</strong></p>
<p>这个是我的测试清单库：<a target="_blank" rel="noopener" href="https://gitee.com/sumumm/manifest">manifest: repo的清单库 (gitee.com)</a>，后来改成这个名字了：<a target="_blank" rel="noopener" href="https://gitee.com/sumumm/repo-manifest/tree/bf06c8ce913ec6a94ffeb4e31ac39f28bc3fad20">repo-manifest: repo的清单库 - Gitee.com</a></p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240927225008913.png" alt="image-20240927225008913" />

<h1 id="三、相关命令"><a href="#三、相关命令" class="headerlink" title="三、相关命令"></a><font size=3>三、相关命令</font></h1><h2 id="1-repo-init"><a href="#1-repo-init" class="headerlink" title="1. repo init"></a><font size=3>1. repo init</font></h2><h3 id="1-1-命令说明"><a href="#1-1-命令说明" class="headerlink" title="1.1 命令说明"></a><font size=3>1.1 命令说明</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo init -u &lt;URL&gt; [&lt;OPTIONS&gt;]</span><br></pre></td></tr></table></figure>

<ul>
<li><p>-u：指定manifests这个远程git库的URL，manifests库是整个项目的清单。默认情况，这个git库只包含了default.xml一个文件，其内容可以参见Android的样本</p>
</li>
<li><p>-m， –manifest-name：指定所需要的manifests库中的清单文件。默认情况下，会使用maniftests&#x2F;default.xml</p>
</li>
<li><p>-b， –manifest-branch：指定manifest.xml文件中的一个版本，，也就是俗称的“分支”</p>
</li>
</ul>
<p>还有这几个参数可能也会用到：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">repo Version options:</span><br><span class="line">    --repo-url=URL      repo repository location ($REPO_URL)</span><br><span class="line">    --repo-rev=REV      repo branch or revision ($REPO_REV)</span><br><span class="line">    --no-repo-verify    do not verify repo source code</span><br></pre></td></tr></table></figure>

<ul>
<li>–-repo-url：指定远程repo库的URL，默认情况是<a target="_blank" rel="noopener" href="https://gerrit.googlesource.com/git-repo">https://gerrit.googlesource.com/git-repo</a>，但国内访问Google受限，会导致这个库无法下载，从而导致repo init失败，所以可以通过该参数指定一个访问不受限的repo地址。</li>
<li>–repo-rev：同manifest这个git库一样，repo这个git库也是有版本差异的，可以通过该参数来指定下载repo这个远程git库的特定分支。</li>
<li>–no-repo-verify：在下载repo库时，会对repo的源码进行检查。通过–repo-url指定第三方repo库时，可能会导致检查不通过，所以可以配套使用该参数，强制不进行检查。</li>
</ul>
<p>运行该命令后，会在当前目录下新建一个.repo子目录：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">.repo</span><br><span class="line">├── manifests     # 一个git库，包含default.xml文件，用于描述repo所管理的git库的信息</span><br><span class="line">├── manifests.git # manifest这个git库的实体，manifest/.git目录下的所有文件都会链接到该目录</span><br><span class="line">├── manifest.xml  # manifests/default.xml的一个软链接</span><br><span class="line">└── repo          # 一个git库，包含repo运行的所有脚本</span><br></pre></td></tr></table></figure>

<h3 id="1-2-命令参考"><a href="#1-2-命令参考" class="headerlink" title="1.2 命令参考"></a><font size=3>1.2 命令参考</font></h3><p>这些本地的目录是如何生成的呢？执行repo命令时，可以通过-–trace参数，来看实际发生了什么。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo --trace init -u $URL -b $BRANCH -m $MANIFEST</span><br></pre></td></tr></table></figure>

<p>有的时候我们忘记设置git-repo源码位置的话，就会从默认地址下载源码，但是这又需要科学上网，就导致会失败，所以我们可以按照<a target="_blank" rel="noopener" href="https://mirrors.tuna.tsinghua.edu.cn/help/git-repo/">git-repo | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror</a>这里说的，修改环境变量，当然也可不修改，我们可以使用上面的两个参数：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo init --repo-url=&lt;git-repo SRC_URL&gt; --repo-rev=&lt;git-repo SRC_BRANCH&gt; -u &lt;URL&gt; [&lt;OPTIONS&gt;]</span><br></pre></td></tr></table></figure>

<blockquote>
<p>注意：这里的两个URL都用http地址吧，不然好像会报错。</p>
</blockquote>
<p>参考命令如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo --trace init --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo --repo-rev= -u https://gitee.com/xxx/manifest.git -b master -m xxx.xml</span><br></pre></td></tr></table></figure>

<h3 id="1-3-使用实例"><a href="#1-3-使用实例" class="headerlink" title="1.3 使用实例"></a><font size=3>1.3 使用实例</font></h3><p>上面我们已经设置完了环境变量，然后我的manifest目录是：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://gitee.com/sumumm/manifest.git # 为了防止输入账号密码，我后面用的实SSH链接</span><br></pre></td></tr></table></figure>

<p>初始化的命令如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo init https://gitee.com/sumumm/manifest.git -m default.xml</span><br></pre></td></tr></table></figure>

<p>我们还可加上–trace参数：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo --trace init https://gitee.com/sumumm/manifest.git -m default.xml</span><br></pre></td></tr></table></figure>

<p>会看到有如下打印信息：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240927225805883.png" alt="image-20240927225805883" />

<p>（1）在当前目录下创建.repo子目录，后续所有的操作都在.repo子目录下完成;</p>
<p>（2）clone了两个git库，其中一个是-u参数指定的manifests，本地git库的名称是manifest.git;另一个是默认的repo，后面我们会看到这个URL也可以通过参数来指定;</p>
<p>（3）创建了manifest&#x2F;.git目录，里面的所有文件都是到manifests.git这个目录的链接，这个是为了方便对manifests目录执行git命令，</p>
<p>（4）将manifest切换到-b参数指定的分支;</p>
<p>（5）在.repo目录下，创建了一个软链接，链接到-m参数制定的清单文件，默认情况是manifests&#x2F;default.xml。</p>
<p>这样，就完成了一个多git库的初始化，之后，就可以执行其他的repo命令了。</p>
<h3 id="1-4-指定清单文件名"><a href="#1-4-指定清单文件名" class="headerlink" title="1.4 指定清单文件名"></a><font size=3>1.4 指定清单文件名</font></h3><blockquote>
<p>注意：这一部分的实例中清单库的名字后来我改掉了：<a target="_blank" rel="noopener" href="https://gitee.com/sumumm/repo-manifest/tree/83208b92c82afce95f07c8e0df8f3db11c32705d">repo-manifest: repo的清单库 - Gitee.com</a></p>
</blockquote>
<p>其实这里也不一定非要用default.xml，由于这个清单库的名字是固定的，我们不可能用这一个清单库只管理一个项目吧，那岂不是很浪费。前面我们知道这里是可以指定使用的xml文件的，所以我们可以修改清单库中默认xml文件名称为repo-demo.xml然后我们可以通过以下命令来创建一个项目：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo --trace init --repo-url=https://gitee.com/sumumm/git-repo.git --repo-rev=main -u https://gitee.com/sumumm/manifest.git -b master -m repo-demo.xml</span><br></pre></td></tr></table></figure>

<p>自定义git-repo源码仓库的时候可能会出现无法访问的情况比如我用了自己github上的仓库，就出现了报错</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928071506236.png" alt="image-20240928071506236" />

<p>但是我导入到gitee上就没问题了：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928071707655.png" alt="image-20240928071707655" />

<p>其实自己也没必要搞这么一个仓库，用清华源的那个就好啦：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo --trace init --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo --repo-rev= -u https://gitee.com/sumumm/manifest.git -b master -m repo-demo.xml</span><br></pre></td></tr></table></figure>

<p>这样也很快，这个不指定git-repo源码仓库分支也可以，就用默认的。所以这样修改xml名字后也完成了repo项目的初始化。我们能不能把xml放到其他文件夹中？我们来试一下（<a target="_blank" rel="noopener" href="https://gitee.com/sumumm/repo-manifest/tree/ee11101a7b24edb90580e856021889c60b06199e">repo-manifest: repo的清单库 - Gitee.com</a>）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo --trace init --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo --repo-rev= -u https://gitee.com/sumumm/manifest.git -b master -m repo-demo/repo-demo.xml </span><br></pre></td></tr></table></figure>

<p>就会发现这样也是可以的：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928073314969.png" alt="image-20240928073314969"  />

<p>我们还可尝试创建链接文件到仓库目录下，这样就不用输入路径了，我们来试一下（<a target="_blank" rel="noopener" href="https://gitee.com/sumumm/repo-manifest/tree/bf06c8ce913ec6a94ffeb4e31ac39f28bc3fad20">repo-manifest: repo的清单库 - Gitee.com</a>）：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo --trace init --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo --repo-rev= -u https://gitee.com/sumumm/manifest.git -b master -m repo-demo.xml</span><br></pre></td></tr></table></figure>

<p>还是这个命令，但是仓库变成这个样子：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928073525695.png" alt="image-20240928073525695" />

<p>我们上传到gitee仓库，是这样的：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928073725564.png" alt="image-20240928073725564" />

<p>需要注意的是windows好像不太支持软链接，可能会有问题，我这个是在ubuntu中测试的。执行上面的命令后，也会创建成功：</p>
<p><img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240928073901142.png" alt="image-20240928073901142"></p>
<h3 id="1-5-指定清单库名"><a href="#1-5-指定清单库名" class="headerlink" title="1.5 指定清单库名"></a><font size=3>1.5 指定清单库名</font></h3><p>清单文件名可以自定义，那清单库名呢，应该也是可以的，我们可以修改清单库名称为：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo --trace init --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo --repo-rev= -u https://gitee.com/sumumm/repo-manifest.git -b master -m repo-demo.xml</span><br></pre></td></tr></table></figure>

<p>尝试一下，就会发现正常创建了.repo目录：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line">sumu@sumu-virtual-machine:~/6RK3568$ repo --trace init --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo --repo-rev= -u https://gitee.com/sumumm/repo-manifest.git -b master -m repo-demo.xml</span><br><span class="line">: git --version</span><br><span class="line">Downloading Repo source from https://mirrors.tuna.tsinghua.edu.cn/git/git-repo</span><br><span class="line">: git init --quiet</span><br><span class="line">: git config remote.origin.url https://mirrors.tuna.tsinghua.edu.cn/git/git-repo</span><br><span class="line">: git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*</span><br><span class="line">: git config --get-regexp url.*.insteadof</span><br><span class="line">remote: Enumerating objects: 8909, done.</span><br><span class="line">remote: Counting objects: 100% (5078/5078), done.</span><br><span class="line">remote: Compressing objects: 100% (2564/2564), done.</span><br><span class="line">remote: Total 8909 (delta 4859), reused 2514 (delta 2514), pack-reused 3831</span><br><span class="line">: git fetch --quiet --progress origin +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*</span><br><span class="line">repo: Updating release signing keys to keyset ver 2.3</span><br><span class="line">: gpg --homedir . --import 0&lt;|</span><br><span class="line">: git rev-parse --verify refs/remotes/origin/stable^&#123;commit&#125;</span><br><span class="line">: git describe 1e19f7dd61923b8835d9c6e1a7e560575dafaf1e</span><br><span class="line">: git tag -v v2.47</span><br><span class="line">: git update-ref refs/heads/default v2.47^0</span><br><span class="line">: git config branch.default.remote origin</span><br><span class="line">: git config branch.default.merge refs/heads/stable</span><br><span class="line">: git symbolic-ref HEAD refs/heads/default</span><br><span class="line">: git read-tree --reset -u -v HEAD</span><br><span class="line">: git --version</span><br><span class="line">: /usr/bin/python3 /home/sumu/6RK3568/.repo/repo/main.py --repo-dir=/home/sumu/6RK3568/.repo --wrapper-version=2.45 --wrapper-path=/home/sumu/2software/repo_bin/repo -- --trace init --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo --repo-rev= -u https://gitee.com/sumumm/repo-manifest.git -b master -m repo-demo.xml</span><br><span class="line"></span><br><span class="line">Your identity is: sumu &lt;2038035593@qq.com&gt;</span><br><span class="line">If you want to change this, please re-run &#x27;repo init&#x27; with --config-name</span><br><span class="line"></span><br><span class="line">Testing colorized output (for &#x27;repo diff&#x27;, &#x27;repo status&#x27;):</span><br><span class="line">  black    red      green    yellow   blue     magenta   cyan     white </span><br><span class="line">  bold     dim      ul       reverse </span><br><span class="line">Enable color display in this user account (y/N)? y</span><br><span class="line"></span><br><span class="line">repo has been initialized in /home/sumu/6RK3568</span><br></pre></td></tr></table></figure>

<h2 id="2-repo-sync"><a href="#2-repo-sync" class="headerlink" title="2. repo sync"></a><font size=3>2. repo sync</font></h2><h3 id="2-1-命令说明"><a href="#2-1-命令说明" class="headerlink" title="2.1 命令说明"></a><font size=3>2.1 命令说明</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo sync [PROJECT_LIST]</span><br></pre></td></tr></table></figure>

<p>下载远程代码，并将本地代码更新到最新，这个过程称为“同步”。如果不使用任何参数，那么会对所有repo管理的进行同步操作。也可以PROJECT_LIST参数，指定若干要同步的PROJECT。 根据本地git库代码不同，同步操作会有不同的行为：</p>
<p>（1）当本地的git库是第一次触发同步操作时，那么，该命令等价于git clone，会将远程git库直接拷贝到本地。</p>
<p>（2）当本地已经触发过同步操作时，那么，该命令等价于git remote update &amp;&amp; git rebase origin&#x2F;，就是当前与本地分支所关联的远程分支 代码合并可能会产生冲突，当冲突出现时，只需要解决完冲突，然后执行git rebase –continue即可。当sync命令正确执行完毕后，本地代码就同远程代码保持一致了。</p>
<p>在一些场景下，我们会用到sync命令的一些参数：</p>
<ul>
<li><p>-j：开启多线程同步操作，这会加快sync命令的执行速度。默认情况下，使用4个线程并发进行sync</p>
</li>
<li><p>-c, –current-branch：只同步指定的远程分支。默认情况下，sync会同步所有的远程分支，当远程分支比较多的时候，下载的代码量就大。使用该参数，可以缩减下载时间，节省本地磁盘空间</p>
</li>
<li><p>-d, –detach：脱离当前的本地分支，切换到manifest.xml中设定的分支。在实际操作中，这个参数很有用，当我们第一次sync完代码后，往往会切换到dev分支进行开发。如果不带该参数使用sync， 则会触发本地的dev分支与manifest设定的远程分支进行合并，这会很可能会导致sync失败</p>
</li>
<li><p>-f, –force-broken：当有git库sync失败了，不中断整个同步操作，继续同步其他的git库。</p>
</li>
</ul>
<h3 id="2-2-使用实例"><a href="#2-2-使用实例" class="headerlink" title="2.2 使用实例"></a><font size=3>2.2 使用实例</font></h3><p>上面我们已经初始化好repo项目了，接下来我们同步一下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo sync</span><br></pre></td></tr></table></figure>

<p>会看到有如下打印信息：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20240927230359007.png" alt="image-20240927230359007" />

<p>我们进到仓库中查看提交记录，会发现与原来的仓库一致。但是我们进入仓库查看一下现在在哪个分支，会看到如下内容：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20241025193101054.png" alt="image-20241025193101054" />

<p>会发现其实现在仓库是处于一个分离头指针状态，没有任何分支，我们可以手动使用<code>git switch -c branch_name</code>创建分支，但是当项目很多的时候就很繁琐了，我们继续向后看repo start命令。</p>
<h2 id="3-repo-start"><a href="#3-repo-start" class="headerlink" title="3. repo start"></a><font size=3>3. repo start</font></h2><h3 id="3-1-命令说明"><a href="#3-1-命令说明" class="headerlink" title="3.1 命令说明"></a><font size=3>3.1 命令说明</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo start &lt;newbranchname&gt; [--all | &lt;project&gt;...]</span><br></pre></td></tr></table></figure>

<p>命令用于在一个或多个项目中创建一个新的分支。它使得开发者能够方便地从当前的代码状态开始新的开发工作，尤其在处理多项目代码库时非常有用。</p>
<ul>
<li>newbranchname：是自定义的，它将追踪manifest中指定的分支名。</li>
<li>project：指定了将参与此主题分支的项目。</li>
<li>–all表示所有的项目都开始新的分支。</li>
</ul>
<p>repo start是对git checkout -b 命令的封装。这条指令与git checkout -b 还是有很大的区别的，git checkout -b 是在当前所在的分支的基础上创建特性分支，而repo start是在清单文件中设定的分支的基础上创建特性分支。例如：repo start  stable  –all（所有项目）</p>
<p>假设清单文件中设定的分支是gingerbread-stable，那么执行以上指令就是对所有项目，在gingerbread-stable的基础上创建特性分支stable。</p>
<h3 id="3-2-使用实例"><a href="#3-2-使用实例" class="headerlink" title="3.2 使用实例"></a><font size=3>3.2 使用实例</font></h3><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">repo start master --all</span><br></pre></td></tr></table></figure>

<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/02%E5%BC%80%E5%8F%91%E5%B7%A5%E5%85%B7/03%E7%89%88%E6%9C%AC%E6%8E%A7%E5%88%B6/LV03-repo-03-%E4%BB%8E0%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AArepo%E7%AE%A1%E7%90%86%E7%9A%84%E9%A1%B9%E7%9B%AE/img/image-20241025193736299.png" alt="image-20241025193736299" />

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/58627ebd.html">LV03-repo-03-从0搭建一个repo管理的项目</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2024年10月26日 - 22:41</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/58627ebd.html" title="LV03-repo-03-从0搭建一个repo管理的项目">https://sumumm.github.io/post/58627ebd.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/Git/" rel="tag"><i class="fa fa-tag"></i> Git</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/ea5e182c.html" rel="prev" title="LV03-repo-04-xml文件说明">
                  <i class="fa fa-angle-left"></i> LV03-repo-04-xml文件说明
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/d94f8cde.html" rel="next" title="LV03-repo-02-repo基本原理">
                  LV03-repo-02-repo基本原理 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
